package com.sixkey.controller.app;


import com.sixkey.entity.Feedback;
import com.sixkey.response.Response;
import com.sixkey.service.IFeedbackService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2023-10-18
 */

/**
 * 用户反馈
 */

@Slf4j
@Validated
@CrossOrigin
@RestController
@RequestMapping("/api/feedback")
@RequiredArgsConstructor
public class ApiFeedbackController {

    private final IFeedbackService feedbackService;

    /**
     * 小程序端用户反馈数据展示
     * @param
     * @return
     */
    @GetMapping("/list")
    public Response list(){
        log.info("小程序端用户反馈数据展示请求进来~");
        List<Feedback> list = feedbackService.getFeedbackList();
        return Response.success(list);
    }

    /**
     * 小程序端用户反馈数据保存
     * @param
     * @return
     */
    @PostMapping("/save")
    public Response save(@RequestBody @Valid Feedback feedback){
        log.info("小程序端用户反馈数据保存请求进来~");
        feedbackService.save(feedback);
        //TODO:等待管理员审核
        return Response.success();
    }
}
